var calPoints = function(ops) {
    let result = []
    let num =0
    for(var i = 0;i<ops.length;i++){
       const item = ops[i]
       if(item==="C"){
           result.pop()
       }else if(item==='D'){
           result.push(Number(result[result.length-1]*2))
       }else if(item === '+'){
           result.push(Number(result[result.length-2])+Number(result[result.length-1]))
       }else{
           result.push(item)
       }
    }
    console.log("结果",result);
    let sum = result.reduce((old,cur)=>{
        return Number(old)+Number(cur)
    })
    console.log(sum);
   return sum
};

calPoints(["5","2","C","D","+"])